package com.service.impl;



import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dao.PersonalDao;
import com.dto.UserInfo;
import com.service.PersonalService;

@Service
public class PersonalServiceImpl implements PersonalService{
	
	@Autowired
	private PersonalDao pd;
	
	//根据name查询数据表中客户的个数
	@Override
	public int getCountByName(String name) {
		int i=pd.getCountByName(name);
		return i;
	}
	
	//根据id更新客户信息
	@Override
	public int updateUserInfoById(UserInfo user) {
		int i=pd.updateUserInfoById(user);
		return i;
	}
	
	//根据id查询用户
	@Override
	public UserInfo getUserInfoById(String u_id) {
		UserInfo user=pd.getUserInfoById(u_id);
		return user;
	}
	
	//根据用户名修改密码
	@Override
	public int updatePasswordByName(UserInfo user) {
		int i=pd.updatePasswordByName(user);
		return i;
	}
	
	//根据绑定手机号发送验证
	@Override
	public int intoCode(String phone) {
		//随机出验证码
		String code=(int)(Math.random()*9000)+1000+"";
		//调用短信接口类
		/*InterfaceModule im=new InterfaceModule();*/
		/*im.noteInterface(phone, code);*/
		//将验证码和电话号码存入数据库
		Map<String,String> map=new HashMap<String,String>();
		map.put("phone", phone);
		map.put("code", code);
		int i=pd.intoCode(map);
		return i;
	}
	
	//根据验证码和电话号验证
	@Override
	public String getPhoneByCodeAndPhone(Map<String,String> map) {
		String s=pd.getPhoneByCodeAndPhone(map);
		return s;
	}

	//判断新手机号是否已存在
	@Override
	public int getCountByPhone(String newphone) {
		int i=pd.getCountByPhone(newphone);
		return i;
	}

	//根据id修改绑定手机号
	@Override
	public int updatePhoneById(UserInfo user) {
		int i=pd.updatePhoneById(user);
		return i;
	}

	
	
	
	

}
